package cn.java78.jdbc;

import cn.myschool.util.DBUtil;

import java.sql.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class StudentSearch2 {
    //有错
    public static void main(String[] args) {
        Connection connection = null;
        PreparedStatement st = null;
        ResultSet rs = null;
        try {
            String sql="select ?,?,?,? from s_student order by stuno desc limit 0,20";

            connection = DBUtil.getConnection();
            st = connection.prepareStatement(sql);
            st.setString(1,"qq");
            st.setString(2,"enterdate");
            st.setString(3,"telephone");
            st.setString(4,"sex");
            rs = st.executeQuery();
            while (rs.next()){
                System.out.println(rs.getObject(1));
                System.out.println(rs.getObject(2));
                System.out.println(rs.getObject(3));
                System.out.println(rs.getObject(4));
                System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.close(rs,st,connection);
        }

    }
}
